import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'

export const constantRoutes: Array<RouteRecordRaw> = [
    {//用户管理、部门管理、角色管理、菜单管理、日志管理、数据字典管理、文件管理、图表展示
        path: '/main',
        name: 'main',
        component: () => import('../components/HomeView.vue'),
        redirect: '/home',
        children: [
            {
                name: "traditional",
                path: "/traditional",
                component: () => import('../pages/Art.vue'),
                meta: {
                    title: "资讯",
                    icon: "Operation"
                },
                children: []
            },     {
                name: "third",
                path: "/third",
                component: () => import('../pages/ThirdPage.vue'),
                meta: {
                    title: "第三方页面",
                    icon: "Operation"
                },
                children: []
            },
            {
                name: "news",
                path: "/news",
                component: () => import('../pages/News.vue'),
                meta: {
                    title: "资讯",
                    icon: "Operation"
                },
                children: []
            }, {
                name: "my",
                path: "/my",
                component: () => import('../pages/My.vue'),
                meta: {
                    title: "我的",
                    icon: "Operation"
                },
                children: []
            }, {
                name: "home",
                path: "/home",
                component: () => import('../pages/Homepage.vue'),
                meta: {
                    title: "主页",
                    icon: "Operation"
                },
                children: []
            }, {
                name: "community",
                path: "/community",
                component: () => import('../pages/Community.vue'),
                meta: {
                    title: "社区",
                    icon: "Operation"
                },
                children: []
            }, {
                name: "contact",
                path: "/contact",
                component: () => import('../pages/Contact.vue'),
                meta: {
                    title: "联系我",
                    icon: "Operation"
                },
                children: []
            }, {
                path: '/:catchAll',
                name: '/404',
                component: () => import('../components/404.vue'),
                children: []
            },

            {
                path: '/districtDetail',
                name: 'districtDetail',
                component: () => import('../pages/DistrictDetail.vue'),
                meta: {
                    title: "地方详情",
                    icon: "Operation"
                },
            },
            {
                path: '/artDetail',
                name: 'artDetail',
                component: () => import('../pages/ArtDetail.vue'),
                meta: {
                    title: "艺术详情",
                    icon: "Operation"
                },
            },
            {
                path: '/storeDetail',
                name: 'storeDetail',
                component: () => import('../pages/StoreDetail.vue'),
                meta: {
                    title: "店铺详细",
                    icon: "Operation"
                },
            },
        ]
    },
    {
        path: '/',
        redirect: '/welcomeVideo'
    },
    {
        path: '/welcomeVideo',
        component: () => import('../pages/WelcomeVideo.vue'),
        children: []
    }, {
        path: '/:catchAll',
        name: '/404',
        component: () => import('../components/404.vue'),
        children: []
    },

]


export const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    linkActiveClass: 'router-checked',
    routes: constantRoutes
})


// 白名单
//const whiteList = ['/login'] // no redirect whitelist
export const permissionsList = ['/Home', '/login', '/HomePage', '/main'] // no redirect whitelist
router.beforeEach((to, from, next) => {
    next()
    /*  if (getToken() != undefined && permissionsList.indexOf(to.path) !== -1) {
          next()
          //没有token并且是前往login页面
      } else if (getToken() == undefined && whiteList.indexOf(to.path) !== -1) {
          // 未登录,跳转到登陆页面
          next()
      } else {
          next({
              path: '/login'
          })
      }*/
})
export default router
